import 'package:flutter/material.dart';
import 'shop_screen_all.dart';
import 'shop_screen_collection.dart';
import 'shop_screen_area.dart';
import 'shop_screen_tag.dart';
import 'package:provider/provider.dart';
import 'shopScreenProvider.dart';

class ShopScreen extends StatelessWidget {


  @override
  Widget build(BuildContext context) {

    final size = MediaQuery.of(context).size;
    List<Widget> tabBarViews = [ShopScreenAll(),ShopScreenCollection(),ShopScreenArea(),ShopScreenTag()];
    
    return DefaultTabController(
      length: tabBarViews.length,
      child: Scaffold(
        appBar: AppBar(
          title: ConstrainedBox(
            constraints: BoxConstraints(
              maxHeight: 40,
              maxWidth: size.height * 0.75
            ),
            child: Consumer<ShopScreenProvider>(
              builder: (context,provider,child){
                return TextField(
                  decoration: InputDecoration(
                    border: OutlineInputBorder(
                      borderRadius: BorderRadius.circular(3),
                    ),
                    disabledBorder: InputBorder.none,
                    enabledBorder: InputBorder.none,
                    focusedBorder: InputBorder.none,
                    prefixIcon:Image.asset('images/common_search.png'),
                    fillColor: Colors.white,
                    filled: true,
                    hintText: '请输入门店名称',
                  ),
                  autocorrect: false,
                  onChanged: (text){
                    provider.searchTextChanged(text);
                  },
                );
              },
            )
          ),
          bottom: TabBar(
            labelColor: Colors.white,
            // 标签指示器的宽度
            indicatorSize: TabBarIndicatorSize.label,
            // 标签指示器的颜色
            indicatorColor: Colors.white,
            // 标签指示器的高度
            indicatorWeight: 2,
            tabs: <Widget>[
              Tab(text: '全部',),
              Tab(text: '收藏',),
              Tab(text: '区域结构',),
              Tab(text: '标签',),
            ],
          ),
        ),
        body: TabBarView(
          children: tabBarViews,
        ),
      ),
    );
  }
}